package com.hursing.tractor.model;

import java.util.LinkedList;

import com.hursing.tractor.baseview.UIView;
import com.hursing.tractor.controller.KittyController;
import com.hursing.tractor.controller.DealController;
import com.hursing.tractor.controller.PlayController;

public class HumanPlayer extends Player {
	
	public HumanPlayer(int position) {
		super(position);
	}
	
	@Override
	public void judgeWhetherFlip(DealController dealController, Card newCard) {
		boolean changed = canChangeFlipAbility(newCard);
		if (changed) {
			dealController.pause();
		}
	}
	
	@Override
	protected void addOneCardToHand(Card card) {
		super.addOneCardToHand(card);
		UIView.sViews[UIView.VIEW_HANDY_CARD].toHandyCardView().addOneCard(card);
	}

	@Override
	protected void removeCardsFromHand(LinkedList<Card> cards) {
		super.removeCardsFromHand(cards);
		UIView.sViews[UIView.VIEW_HANDY_CARD].toHandyCardView().removeCards(cards);
	}

	@Override
	public void playCard(PlayController playController) {
		super.playCard(playController);
		UIView.sViews[UIView.VIEW_PLAY_PANEL].visible(true);
		UIView.sViews[UIView.VIEW_HANDY_CARD].enabled(true);
	}
	
	@Override
	public void doPlayCard(LinkedList<Card> cards) {
		super.doPlayCard(cards);
		UIView.sViews[UIView.VIEW_PREVIOUS_BUTTON].enabled(true);
		UIView.sViews[UIView.VIEW_PLAY_PANEL].visible(false);
		UIView.sViews[UIView.VIEW_PLAY_BUTTON].enabled(false);
		UIView.sViews[UIView.VIEW_HANDY_CARD].enabled(false);
	}

	@Override
	public void buryKitty(KittyController kittyController) {
		super.buryKitty(kittyController);
		UIView.sViews[UIView.VIEW_BURY_BUTTON].enabled(false).visible(true);
		UIView.sViews[UIView.VIEW_HANDY_CARD].enabled(true);
	}
	
	@Override
	public void doBuryCards(LinkedList<Card> cards) {
		super.doBuryCards(cards);
		UIView.sViews[UIView.VIEW_BURY_BUTTON].visible(false);
	}

	@Override
	protected Player sortTrumpCards() {
		UIView.sViews[UIView.VIEW_HANDY_CARD].toHandyCardView().sortCards();
		return super.sortTrumpCards();
	}
	
	@Override
	protected void setFlipAbilityOfSuit(int suit, boolean able) {
		UIView.sViews[UIView.VIEW_FLIP_DIAMOND_BUTTON + suit].enabled(able);
	}
}
